//
//  ViewController.m
//  28-UIViewAnimation2
//
//  Created by 王道林 on 16/8/22.
//  Copyright © 2016年 王道林. All rights reserved.
//

#import "ViewController.h"
#import "UIView+Frame.h"
@interface ViewController ()
@property (nonatomic, strong) UIView *animationView;
@property (nonatomic, strong) UIButton *button;
@property (nonatomic, strong) UIButton *button2;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    self.animationView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)];
    _animationView.backgroundColor = [UIColor redColor];
    [self.view addSubview:_animationView];
    
    
    self.button = [UIButton buttonWithType:UIButtonTypeCustom];
    _button.frame = CGRectMake(100, 100, 200, 200);
    _button.backgroundColor = [UIColor blueColor];
    [self.view addSubview:_button];
    [_button addTarget:self action:@selector(button:) forControlEvents:UIControlEventTouchUpInside];
    
    
    self.button2 = [UIButton buttonWithType:UIButtonTypeCustom];
    _button2.frame = CGRectMake(100, 100, 100, 100);
    _button2.backgroundColor = [UIColor blackColor];
    [_button addTarget:self action:@selector(button:) forControlEvents:UIControlEventTouchUpInside];
    
    
}
// button点击
- (void)button:(UIButton *)button
{
#if 0
    // 参数1 : 需要执行的动画
    // 参数2:  持续时间
    // 参数3 : 动画的特效.
    [UIView transitionWithView:_button duration:5 options: UIViewAnimationOptionTransitionFlipFromLeft animations:^{
        _button.wdl_height = 100;
    } completion:^(BOOL finished) {
        // 动画的嵌套效果.
        
    }];
#endif
    // toView会被添加到FromView的俯视图上, 然后fromview被从俯视图移除
    [UIView transitionFromView:_button toView:_button2 duration:3 options:UIViewAnimationOptionCurveLinear completion:^(BOOL finished) {
        
    }];
    
    
}


- (void)viewDidAppear:(BOOL)animated
{
    
    [super viewDidAppear:animated];
        //参数1:
    //参数2:
    //参数3:0.0~ 1.0 数值越小阻力越小.
    //参数4:
    // 参数5:
    [UIView animateWithDuration:10 delay:0 usingSpringWithDamping:0.9f initialSpringVelocity:1.0f options:UIViewAnimationOptionCurveLinear animations:^{
        _animationView.wdl_width = 100;
        _animationView.wdl_height = 300;
        _animationView.backgroundColor = [UIColor yellowColor];
    } completion:^(BOOL finished) {
        
    }];
    

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
